import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

import vuexPersist from "vuex-persist";
export default new Vuex.Store({
  state: {
    list: [],
  },
  mutations: {
    setlist(state, val) {
      if (localStorage.getItem("vuex")) {
        state.list = JSON.parse(localStorage.getItem("vuex")).list;
      } else {
        state.list = val;
      }
    },
    update(state, obj) {
      state.list[obj.index].desc = obj.value;
    },
  },
  actions: {},
  modules: {},
  plugins: [
    new vuexPersist({
      storage: window.localStorage,
    }).plugin,
  ],
});
